<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //冒泡排序
        // var arr = [3,6,50,-50,50,60,30,20,10,0,2,11]
        // for(var i = 0;i < arr.length - 1;i++){
        //     for(var j = 0;j < arr.length - 1 - i;j++){
        //         if(arr[j] > arr[j + 1]){
        //             var tmp = arr[j]
        //             arr[j] = arr[j + 1]
        //             arr[j + 1] = tmp
        //         }
        //     }
        // }
        // console.log(arr);

        //数组操作
        var origin = [ 10, 20, 30, 40, 50]
        var num = 13
        for(var i in origin){
            if(num < origin[i]){
                origin.splice(i,0,num)
                break
            }else if(num >= origin[origin.length - 1]){
                origin.push(num)
                break
            }
        }
        console.log(origin);
        
        //数组去重
        var origin1 = [ 1, 2, 3, 2, 5, 1, 3, 4, 5, 4, 3, 2, 1 ]
        console.log(origin1);
        var tmp = []
        for(var i = 0;i < origin1.length; i++){
            if(tmp.indexOf(origin1[i]) === -1){
                tmp[tmp.length] = origin1[i]
            }
        }
        console.log(tmp);

        // 有两个数组 arrx arry 两个数组的长度相等 arrx数组中每一位表示的是arry中对应的成员的个数 请将newarray通过程序书写出来
        var arrx = [1,3,2,4,5,2]
        var arry = [4,3,2,4,5,6]
        var newarr = []
        for(var i = 0;i < arry.length;i++){
            for(var j = 1;j <= arrx[i];j++){
                newarr[newarr.length] = arry[i]
                // newarr.push(arry[i])    
            }
        }
        console.log(newarr);
    </script>
</body>
</html>